﻿/*
 * Module Name: LinearInterpolation.cs
 * 
 * Purpose: This is an implementation for Linear Interpolation
 * 
 * Created by: Chris Tisdale
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common_Code.Math_Extensions
{
    public class LinearInterpolation
    {
        /*
         * Name: CalcInterpolation
         * 
         * Parameters: double x0
         *             double x1
         *             double y0
         *             double y1
         *             double x
         * 
         * Returns: The interpolated value for x
         * 
         * Purpose: To get the interpolated value for x
         */
        public double CalcInterpolation(double x0, 
                                        double x1, 
                                        double y0, 
                                        double y1, 
                                        double x)
        {
            double y = 0;
            y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));
            return y;
        }
    }
}
